
$(function () {
    //doc: http://bootstrap-table.wenzhixin.net.cn/zh-cn/documentation/
    $('#dataList').bootstrapTable({
        url: '/bflow/defineProcess/list',
        search: true,
        showToggle: true,
        pagination: true,
        showRefresh: true,
        striped: true,
        showColumns: true,
        toolbar: "#toolbar",
        onClickRow:function (row, $element) {
            $($element).addClass('info');
            $($element).siblings().removeClass('info');
        },
    });
});

function formatterStatus(value, row, index) {
    var css = "1"==value?"success":"default";
    var text = "1"==value?"有效":"无效";
    var str = '<label class="label label-'+css+'">'+text+'</label>';
    return str;
}

function formatterType(value, row, index) {
    var css = "def"==value?"success":"warning";
    var text = "def"==value?"默认":"自定义";
    var str = '<label class="text-'+css+'">'+text+'</label>';
    return str;
}


function formatterKey(value, row, index) {
    var link = '<a href="/static/bflow/ui/define/processView.html?id=' + row.id + '&version='+row.version +'" class="btn btn-info btn-xs mgl-10">'+value+'</a>';
    return value;
}

function formatterOperation(value, row, index) {
    var buts = '<a href="/static/bflow/ui/define/processForm.html?id=' + row.id + '&version='+row.version +'" class="btn btn-primary btn-xs">编辑</a>';
    // buts += '<a href="/static/bflow/ui/define/processDrawBoard.html?id=' + row.id + '&version='+row.version +'" class="btn btn-info btn-xs mgl-10">画板</a>';
    buts += '<a href="/static/bflow/ui/drawBoard/drawEdit.html?procId='+row.id+'"class="btn btn-info btn-xs mgl-10">画板</a>';
    buts += '<a href="javascript:;"  onclick="deploy(\'' + row.id + '\')" class="btn btn-warning btn-xs" style="margin-left: 5px">部署</a>';
    return buts;
}


function deploy(id) {
    dialogConfirm("", function(){
        HttpUtil.ajaxAsyncJsonPost("/bflow/defineProcess/deploy", {id: id}, function(message){
            dialogTipSuccess(message);
            refreshPage(1500);
        });
    }, "确定部署该流程吗？");
}